﻿using System;
using System.Collections.Generic;

using SiteUnity.Frame.Common.Tools;
using SiteUnity.Frame.Common.Tools.Class;

namespace SiteUnity.Layers.Entity.General
{
    [Serializable]
    public class Website
    {
        #region Constructor
        public Website() { }
        #endregion

        #region Properties
        private Guid _guid;
        public Guid Guid
        {
            get
            {
                _guid = new Guid(Setting.GetAppSetting("WebsiteGuid"));
                return _guid;
            }
            set
            {
                _guid = value;
            }
        }

        public string Name { get; set; }

        public string Url { get; set; }

        public string Description { get; set; }

        public string ImageUrl { get; set; }

        public DateTime Date { get; set; }
        #endregion

        #region Additional Properties
        public string RawUrl { get; set; }

        public List<Page> Pages { get; set; }

        public Page CurrentPage
        {
            get
            {
                return SelectPageByUrl(RawUrl);
            }
        }
        #endregion

        #region Methods
        public Page SelectPageByUrl(string PageUrl)
        {
            Page result = ClassCollection.Find<Page>(Pages, "Url", RawUrl);

            if (result.Guid != default(Guid))
                return result;

            return Pages[0];
        }
        #endregion
    }
}
